﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace System.web.mvc
{
    // Summary:
    //     Provides an attribute that compares two properties of a model.
    [AttributeUsage(AttributeTargets.Property)]
    public class CompareAttribute : ValidationAttribute, IClientValidatable
    {
        // Summary:
        //     Initializes a new instance of the System.Web.Mvc.CompareAttribute class.
        //
        // Parameters:
        //   otherProperty:
        //     The property to compare with the current property.
        public CompareAttribute(string otherProperty);

        // Summary:
        //     Gets the property to compare with the current property.
        //
        // Returns:
        //     The property to compare with the current property.
        public string OtherProperty { get; }

        // Summary:
        //     Applies formatting to an error message based on the data field where the
        //     compare error occurred.
        //
        // Parameters:
        //   name:
        //     The name of the field that caused the validation failure.
        //
        // Returns:
        //     The formatted error message.
        public override string FormatErrorMessage(string name);
        //
        // Summary:
        //     Formats the property for client validation by prepending an asterisk (*)
        //     and a dot.
        //
        // Parameters:
        //   property:
        //     The property.
        //
        // Returns:
        //     The string "*." is prepended to the property.
        public static string FormatPropertyForClientValidation(string property);
        //
        // Summary:
        //     Gets a list of compare-value client validation rules for the property using
        //     the specified model metadata and controller context.
        //
        // Parameters:
        //   metadata:
        //     The model metadata.
        //
        //   context:
        //     The controller context.
        //
        // Returns:
        //     A list of compare-value client validation rules.
        public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context);
        //
        // Summary:
        //     Determines whether the specified object is equal to the compared object.
        //
        // Parameters:
        //   value:
        //     The value of the object to compare.
        //
        //   validationContext:
        //     The validation context.
        //
        // Returns:
        //     null if the value of the compared property is equal to the value parameter;
        //     otherwise, a validation result that contains the error message that indicates
        //     that the comparison failed.
        protected override ValidationResult IsValid(object value, ValidationContext validationContext);
    }
}
